package com.yulan.bankback.entity.model.admin;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.yulan.bankback.entity.model.bank.BankUser;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.ToString;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
@ToString
public class KindUser {

    @TableId
    private String uid;

    private String username;

    private Date createTime;

    private String type;

    private String blackOrWhite;

    @TableField(exist = false)
    private String viewTime;

    public KindUser(String uid, String username, Date createTime, String type, String blackOrWhite) {
        this.uid = uid;
        this.username = username;
        this.createTime = createTime;
        this.type = type;
        this.blackOrWhite = blackOrWhite;
    }

    public static KindUser convertFromUser(BankUser user, String blackOrWhite, String type){
        KindUser kindUser = new KindUser();
        kindUser.setUid(user.getId());
        kindUser.setUsername(user.getUserName());
        kindUser.blackOrWhite = blackOrWhite;
        kindUser.type = type;
        kindUser.createTime = new Date();
        return kindUser;
    }
}
